home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Developers / Selection ƒ 2.5 / picture < prev    next >
Encoding:
Text File  |  1994-11-06  |  1.4 KB  |  73 lines  |  [TEXT/MSET]

  1.  \ 06Nov94 dbh updated to 2.5 syntax
  2.  
  3. (*
  4.  
  5. We decide that a picture is a lot like a rectangle, so we make class picture
  6. a subclass of rect+ along with our nullselect class so we can use picture objects
  7. in our selection framework.  Also we use class OwnerObj as a superclass so we
  8. can easily implement scrolling.
  9.  
  10. We are defaulting to a PICT resource ID of 400.  This won't
  11. work of course unless we have such a resource available.
  12. You should make sure you have placed the resource file
  13. Selection.rsrc into your Mops ƒ folder.
  14.  
  15. We provide the expected behavior and methods, and also provide a normal:
  16. method which will set the rect+ ivar data to match the PICT resource.
  17. Also we provide a frame: method to draw a black border around the
  18. picture, if desired.
  19.  
  20. *)
  21.  
  22. :class picture super{ rect+ nullSelect OwnerObj }
  23.     resource+    res
  24.  
  25. :m set:    ( resID -- )
  26.     'type PICT swap set: res ;m
  27.  
  28. :m classinit:
  29.     400 set: self ;m
  30.     
  31. :m new:    ( wptr -- )
  32.     drop
  33.     getnew: res
  34.     normal: [self] ;m
  35.  
  36. :m draw:
  37.     get: res ( PicHandle)
  38.     self ( dstRect)
  39.     call DrawPicture ;m
  40.  
  41. :m normal:    { \ prect -- }
  42.     ptr: res   2 + -> prect
  43.     prect width: rect+   setwidth: super
  44.     prect height: rect+   setheight: super
  45.     ;m
  46.  
  47. :m frame:
  48.     draw: self
  49.     call PenNormal
  50.     draw: super ;m
  51.  
  52. :m release:
  53.     release: res ;m
  54.  
  55. ;class
  56.  
  57.  
  58. endload
  59.  
  60. *** EXAMPLE USE
  61.  
  62. \ Make sure that the resource file Selection.rsrc has been placed into your Mops ƒ folder.
  63.  
  64.  
  65. " Selection.rsrc" OpenResFile
  66.  
  67. selwindow w
  68. test: w
  69.  
  70. picture p
  71. p add: w
  72.  
  73.